
const GlobalFunctions ={
  isEmptyobj,
  getAppointedDate,
}

 function isEmptyobj(str) {
    if (str === '' || str === null || str === 'null' || str === undefined || str === 'undefined') {
      return true;
    } else {
      return false;
    }
  }
  function getAppointedDate(periodunit, periods, signingtime) {
    let nowDay = signingtime._d.getDate(); //当前日
    let nowMonth = signingtime._d.getMonth() + 1; //当前月
    let nowYear = signingtime._d.getFullYear(); //当前年
    let nums = Number(periods);

    if (periodunit === "年") {
      nowYear = nowYear + nums;
    } else if (periodunit === "半年") {
      nowYear = nowYear + Math.round(nums / 2, 0);
      nowMonth = nowMonth + (nums % 2) * 6;
    } else if (periodunit === "月") {
      nowMonth = nowMonth + nums;
    }
    if (nowDay > 1) {
      nowDay = nowDay - 1;
    } else {
      nowMonth = nowMonth - 1;
      let nowmode = nowMonth % 12;
      if (nowmode === 1 || nowmode === 3 || nowmode === 5 || nowmode === 7 || nowmode === 8 || nowmode === 10 || nowmode === 0) {
        nowDay = 31;
      } else if (nowmode === 4 || nowmode === 6 || nowmode === 9 || nowmode === 11) {
        nowDay = 30;
      } else {
        nowDay = 28;
      }
    }
    if (nowMonth > 12) {
      nowYear = nowYear + 1;
      nowMonth = nowMonth - 12;
    }
    return new Date(nowYear, nowMonth - 1, nowDay);
  }
export default GlobalFunctions;